#include "xrouter_handle.h"
#include <XTools.h>
#include "xservice_proxy.h"
#include <protobuf/xmsg_com.pb.h>
void XRouterHandle::readCB(xmsg::XMsgHead *head, XMsg *msg)
{
    // 转发消息
    XCOM_LOG_DEBUG("XRouterHandle::readCB");
#ifdef XCOM_DEBUG
    xmsg::XDirReq req;
    if(!req.ParseFromArray(msg->data,msg->size))
    {
        XCOM_LOG_ERROR("XRouterHandle::readCB req.ParseFromString is not true");
        return;
    }
    if(req.path().empty())
    {
        XCOM_LOG_ERROR("XRouterHandle::readCB req.path is empty");
        return;
    }
    XCOM_LOG_DEBUG(req.path());
#endif
    if(!XServiceProxy::Get()->SendMsg(head, msg, this))
        XCOM_LOG_DEBUG("XServiceProxy::GetInstance()->SendMsg is not true");;
    return;
}

bool XRouterHandle::Close()
{
    if(!XMsgEvent::Close()){
        return false;
    }
    XCOM_LOG_DEBUG("XRouterHandle::Close");
    XServiceProxy::Get()->DelEvent(this);
    return true;
}
